<template>
  <div class="navbar">
    <div class="nav-bar-item" v-for="(item,index) in tabTitle" :class="{active:index===occurrindex}" @click="itemClick(index)" >
      <span>
        {{item}}
      </span>
    </div>
  </div>
</template>

<script>
  export default {
    name: "tableControl",
    props:{
      tabTitle:{
        type:Array,
        default:[]
      }
    },
    data(){
      return{
        occurrindex:0,
      }
    },
    methods:{
      itemClick(index){
        this.occurrindex=index;
        this.$emit('itemClick',index)
      }
    }
  }
</script>

<style scoped>
  .navbar{
    height: 40px;
    display: flex;

  }
  .nav-bar-item{
    flex: 1;
    text-align: center;
    line-height: 40px;
    box-shadow:0 1px 0 rgba(100,100,100,0.2);
  }
  .nav-bar-item span{
    font-size: 14px;

  }
  .active{
    color: red;
  }

</style>